package com.chixing.controller;


import com.chixing.entity.MovieDetail;
import com.chixing.entity.vo.MovieVO;
import com.chixing.service.IMovieDetailService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liwenjing
 * @since 2025-10-07
 */
@RestController
@RequestMapping("/movie-detail")
public class MovieDetailController {
    @Autowired
    private IMovieDetailService movieDetailService;
    @GetMapping("es/loadMovieDetailES")
    public Result saveMovieDetailElasticsearch(){
        return movieDetailService.saveMoviesElasticSearch();
    }

    @GetMapping("es/getByKeyword/{keyword}")
    public List<MovieDetail> getByKeyword(@PathVariable("keyword") String keyword){
        return movieDetailService.getByKeyword(keyword);
    }

    @GetMapping("es/{keyword}/{page}")
    public  List<MovieDetail> getByKeywordAndPage(@PathVariable("keyword") String keyword, @PathVariable("page") Integer page){
        return   movieDetailService.getByKeywordAndPageWithBoxOffice(keyword,page);
    }
}
